﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;

public class AssetBundleTools
{
    static string androidStreamUrl;
    [MenuItem("Assets/Build Android DLL")]
    public static void BuildAssetsAndroidDll()
    {
        androidStreamUrl = Application.streamingAssetsPath + "/myassets.android";
        Object mainAsset = AssetDatabase.LoadMainAssetAtPath("Assets/Dll/MyDllLibrary.bytes");
        BuildPipeline.BuildAssetBundle(mainAsset, null, Application.dataPath + "\\Dll\\myassets.android",
                               BuildAssetBundleOptions.None, BuildTarget.Android);
        if (File.Exists(androidStreamUrl))
        {
            File.Delete(androidStreamUrl);
        }

        //拷贝到Stream目录下方便程序下载AB文件
        File.Copy(Application.dataPath + "\\Dll\\myassets.android", androidStreamUrl);
        AssetDatabase.Refresh();
    }
}
